package com.cyou.nad.dao.mybatis;

import org.apache.ibatis.session.RowBounds;
import org.springframework.util.Assert;


/**
 *
 * PageRowBounds.
 * <p>
 * Function: <br>
 * 封装分页参数实体类
 * </p>
 * date: 2012-8-10 下午2:28:02
 *
 * @version
 * @author yuanchao
 */
public class PageRowBounds extends RowBounds {

	/**
	 * Creates a new instance of PageRowBounds.
	 *
	 * @param offset 起始位置
	 * @param limit 每页最大条数
	 */
	private PageRowBounds(int offset, int limit){
		super(offset,limit);
	}
	
	public static PageRowBounds getInstance(int pageNo,int pageSize){
		Assert.isTrue(pageNo >= 1, "pageNo 应该从1开始");
		Assert.isTrue(pageSize >= 1, "pageSize 应该大于等于1");
		int offset = (pageNo - 1) * pageSize;
		return new PageRowBounds(offset,pageSize);
	}
	/**
	 * totalCount: 结果集总条数.
	 */
	private int totalCount=0;

	/**
	 * getTotalCount:.
	 *
	 * @author yuanchao
	 * @return 结果集总条数
	 */
	public int getTotalCount(){
		return totalCount;
	}

	/**
	 * setTotalCount:设置结果集总条数.
	 *
	 * @author yuanchao
	 * @param totalCount 总条数
	 */
	public void setTotalCount(int totalCount){
		this.totalCount = totalCount;
	}
}

